package com.tingyuge.base.thread.wang.chapter5;

import java.util.Optional;
import java.util.stream.IntStream;

public class ThreadPriorityTest {

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            IntStream.range(0,1000).forEach(it->{
                Optional.of(Thread.currentThread().getName()+"->"+it).ifPresent(System.out::println);
            });

        });
        Thread t2 = new Thread(()->{
            IntStream.range(0,1000).forEach(it->{
                Optional.of(Thread.currentThread().getName()+"->"+it).ifPresent(System.out::println);
            });

        });
        Thread t3 = new Thread(()->{
            IntStream.range(0,1000).forEach(it->{
                Optional.of(Thread.currentThread().getName()+"->"+it).ifPresent(System.out::println);
            });

        });

        t1.start();
        t1.setPriority(Thread.MAX_PRIORITY);
        t2.start();
        t2.setPriority(Thread.MIN_PRIORITY);
        t3.start();
        t3.setPriority(Thread.NORM_PRIORITY);
    }
}
